unit Con_Taxa;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
  DB, DbTables, TFlatButtonUnit;

type
  TFrmCon_Taxa = class(TFrmConsulta)
    dbgTaxa: TDBGrid;
    btnGravar: TFlatButton;
    procedure BtnFecharClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure btnGravarClick(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Taxa_Periodo: string;
  end;

var
  FrmCon_Taxa: TFrmCon_Taxa;

implementation
uses Dm, Biblio, clsTaxa, Cad_Taxa, menu;

{$R *.DFM}

var
  Taxa: TTaxa;
  tds: Tdatasource;
  tq: Tquery;

procedure TFrmCon_Taxa.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Taxa_Periodo := tq.fieldbyname('Taxa_Periodo').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_Taxa.FormActivate(Sender: TObject);
begin
  inherited;
  if FileExists(caminho_personal + 'belquimica') then begin
    btnGravar.Visible := False;
  end;
  tds := TDataSource.create(FrmCon_Taxa);
  tq := Tquery.create(FrmCon_Taxa);
  tq.databasename := dmint.db.databasename;
  tq.active := False;
  tds.DataSet := tq;
  fazconsulta;
end;

procedure TfrmCon_Taxa.FazConsulta;
begin
  Taxa := TTaxa.Create;
  Taxa.Consultar(tq);
  tq.open;
  Taxa.free;
  dbgTaxa.DataSource := tds;
  dbgTaxa.Refresh;
end;

procedure TFrmCon_Taxa.btnGravarClick(Sender: TObject);
var
  f1: TfrmCad_Taxa;
begin
  inherited;
  f1 := TfrmCad_Taxa.Create(self);
  f1.btnC_Taxa.Visible := False;
  f1.ShowModal;
  f1.Free;
  FazConsulta;
end;

end.
